<template>
  <d2-container>
    <div slot="header">
      <crud-search
        ref="search"
        :options="crud.searchOptions"
        @submit="handleSearch"
      />
      <crud-toolbar v-bind="_crudToolbarProps" v-on="_crudToolbarListeners" />
    </div>
    <d2-crud-x
      ref="d2Crud"
      v-bind="_crudProps"
      v-on="_crudListeners"
      @view="getDetail"
    ></d2-crud-x>
    <el-drawer
      title="查看入库详情"
      :visible.sync="drawerVisible"
      destroy-on-close
      ><detail :id="rId"></detail
    ></el-drawer>
  </d2-container>
</template>
<script>
import { crudOptions } from './crud'
import { d2CrudPlus } from 'd2-crud-plus'
import api from './api'
import detail from './components/detail'
export default {
  mixins: [d2CrudPlus.crud],
  components: {
    detail
  },
  data () {
    return {
      drawerVisible: false,
      rId: ''
    }
  },
  methods: {
    getCrudOptions () {
      return crudOptions(this)
    },
    pageRequest (query) {
      return api.getInList(query)
    },
    getDetail ($event) {
      this.drawerVisible = true
      this.rId = $event.row._id
      console.log('$event', $event)
    },
    // addRequest (row) { return api.addVolunteer(row) },
    // updateRequest (row) { return api.updateVolunteer(row) },
    delRequest (row) { return api.delIn(row._id) }
  }
}
</script>
